package com.forekonw.demo5;

public class ObjectArray {

    public static void main(String[] args) {
        Emplyee e1 = new Emplyee();
        e1.setNo("1001");
        e1.setName("tom");
        e1.setDept("market");
        e1.setSal(2345.145);

        Emplyee e2 = new Emplyee();
        e2.setNo("1002");
        e2.setName("tony");
        e2.setDept("market");
        e2.setSal(5234.124);
        //创建一个新数组
        Emplyee[] arr = new Emplyee[2];
        //如何向数组当中添加元素
        arr[0] = e1;
        arr[1] = e2;
        //如何获取元素
        Emplyee emp = arr[0];
        System.out.println(emp.getDept()+"---"+emp.getName());


        //遍历数组
        for (int i =0 ; i <arr.length;i++){
            Emplyee e = arr[i];
            System.out.println(e.getName()+"---"+e.getDept());
        }
    }
}
